-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make ImmutableArray readonly #44640
Make ImmutableArray readonly #44640
Conversation
Tagging subscribers to this area: @eiriktsarpalis, @jeffhandley Issue Details
|
@@ -121,7 +122,7 @@ public static bool Update<T>(ref ImmutableArray<T> location, Func<ImmutableArray | |||
Requires.NotNull(transformer, nameof(transformer)); | |||
|
|||
bool successful; | |||
T[]? oldArray = Volatile.Read(ref location.array); | |||
T[]? oldArray = Volatile.Read(ref Unsafe.As<ImmutableArray<T>, T[]?>(ref location)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this use just Unsafe.AsRef
to just cast-away the readonly-ness? Unsafe.As
is too big hammer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense
This may be a problem for Roslyn. @jaredpar ? |
It's a headache to update but not a blocker. |
LGTM. Thank you for your contribution. |
Closes #334 .
I noticed that #44629 does not come with api review. I think this can be done similarly.
As an implementation requirement, this PR brings a new reference of S.R.CS.Unsafe to netstandard1.0 target. It this acceptable?